import 'package:flutter/material.dart';
import 'package:xinxuan/common/appbar_util.dart';
import 'package:xinxuan/common/button_util.dart';
import 'package:xinxuan/common/scroll_configuration_common.dart';
import 'package:xinxuan/controllers/home_controller/home_page_controller.dart';
import 'package:xinxuan/controllers/my_controller/my_page_controller.dart';
import 'package:xinxuan/router/app_routers.dart';
import 'package:xinxuan/utils/color_util.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

class PaySuccessPage extends StatelessWidget {

  final MyPageController myPageController = Get.find();
  final HomePageController homePageController = Get.find();

  @override
  Widget build(BuildContext context) {
    Map<String, dynamic> argumentsMap = Get.arguments;
    bool isDetail = argumentsMap['isDetail'] ?? false;
    // int orderId = argumentsMap['orderId'];
    dynamic result = argumentsMap['result'];
    return Scaffold(
      backgroundColor: bgWhiteColor,
      appBar: AppBarUtil(
        title: '支付成功',
        backgroundColor: pageBgColor,
        result: result
      ),
      body: ScrollConfigurationCommon(child: ListView(
        children: [
          SizedBox(height: 83.h),
          Container(
            alignment: Alignment.center,
            child: Image.asset(
              'assets/icons/icon_pay_success.png',
              width: 160.w,
              height: 160.w,
              fit: BoxFit.cover,
            ),
          ),
          SizedBox(height: 32.h),
          Container(
            alignment: Alignment.center,
            child: Text(
              '恭喜您！支付成功！',
              style: TextStyle(
                color: textBlackColor,
                fontSize: 16.sp
              ),
            ),
          ),
          SizedBox(height: 88.h),
          Container(
            alignment: Alignment.center,
            child: Container(
              width: 186.w,
              child: ButtonUtil(
                text: '查看订单', 
                fontSize: 14.sp, 
                borderRadius: 18.w, 
                textColor: mainTextColor,
                bgColors: [
                  bgWhiteColor,
                  bgWhiteColor
                ],
                showBorder: true,
                height: 36.h, 
                onTop: () {
                  // Get.offAndToNamed(
                  //   '${AppRouters.COMMON_PAGE}${AppRouters.STORE_ORDER_PAGE}',
                  //   arguments: {
                  //     'tabIndex': 0
                  //   }
                  // );
                  if (isDetail) {
                    Get.offNamed(
                      '${AppRouters.COMMON_PAGE}${AppRouters.STORE_ORDER_PAGE}',
                      arguments: {
                        'tabIndex': 0
                      }
                    );
                  } else {
                    Get.back(result: true);
                  }
                }
              ),
            ),
          ),
          Container(
            alignment: Alignment.center,
            margin: EdgeInsets.only(top: 20.h),
            child: Container(
              width: 186.w,
              child: ButtonUtil(
                text: '回到首页', 
                fontSize: 14.sp, 
                borderRadius: 18.w, 
                height: 36.h, 
                onTop: () {
                  myPageController.titleBarOpacity.value = 0.0;
                  // homePageController.subHeight.value = 0;
                  Get.offAllNamed(AppRouters.COMMON_PAGE);
                }
              ),
            ),
          )
        ],
      )),
    );
  }
}